﻿using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Threading.Tasks;
using Extentions;
using log4net;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Cors;
using Microsoft.AspNetCore.Mvc;
using Microsoft.Extensions.Logging;
using Microsoft.AspNetCore.Http;
using TrainingReminderSystem.Bll;
using TrainingReminderSystem.Model;

namespace TrainingReminderSystem.Controllers
{
    /// <summary>
    /// 默认HomeController
    /// </summary>
    [AllowAnonymous]
    public class HomeController : BaseController
    {
        [ResponseCache(Duration = 0, Location = ResponseCacheLocation.None, NoStore = true)]
        public IActionResult Error()
        {
            return View(new ErrorViewModel { RequestId = Activity.Current?.Id ?? HttpContext.TraceIdentifier });
        }

        /// <summary>
        /// 首页
        /// </summary>
        /// <returns></returns>
        public IActionResult Index(IFormCollection form)
        {
            return new RedirectResult("/index.html");
        }

        /// <summary>
        /// 展示页
        /// </summary>
        /// <returns></returns>
        public IActionResult Test(IFormCollection form)
        {
            //Log4NetHelper.Error("123321321错误测试");
            //AspNetCoreHelper.Logger.Error("测试错误");
            //var s = ExHttpContext.Current.Session;
            //var a = 1.1111;
            //s.ExSet("a", a);
            if (Request.ExIsGet())
            {
                return View();
            }
            return View();
            ////TestBll bll2 = new TestBll();
            ////bll2.TestSendEmail();
            ////var b = s.ExGet<int>("a");
            //ProjectBll bll = new ProjectBll();
            ////var resultX = new string[] { "value1", "value2" };
            //////使用日志
            ////_logger.LogInformation($"返回信息：{string.Join(",", resultX)}");
            //var result = bll.GetListByPage(PageIndex, PageSize, form);
            ////"XXXX".ExLog("/aaa");
            //result.Message = "";
            //return result.ToContent();
        }

        #region 一些测试

        [HttpPost]
        public IActionResult SomeTest()
        {
            AjaxResult<string> r = new AjaxResult<string>();
            r.Message = "SomeTest";
            r.Success = true;
            return r.ToContent();
        }

        #endregion
    }
}
